// withOverride.js
import React from 'react';
import { getComponent } from './registry';

function withOverride(library, componentName, OriginalComponent) {
    return React.forwardRef((props, ref) => {
        console.log("🚀 ~ returnReact.forwardRef ~ props, ref:", props, ref)
        const ReplacementComponent = getComponent(library, componentName);
        if (ReplacementComponent) {
            return <ReplacementComponent ref={ref} {...props} OriginCom={OriginalComponent} />;
        }

        // 使用原始组件
        return <OriginalComponent ref={ref} {...props} />;
    });
}

export default withOverride;
